// pages/indexLocation/indexLocation.js
var util = require('../../utils/util.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    off_search: true, //无搜索结果状态
    hotItem: [],
    cityLine: [],
    city_name: "",
  },
  onLoad(option) {

    var that = this;
    if (option.city_name) {
      that.setData({
        city_name: option.city_name,
      })
    }

    util.postUrl('index/get_area_list', {}, function(res) {
      if (res.data.code == 200) {
        console.log('dingwei', res.data.datas.list);
        that.setData({
          hotItem: res.data.datas.list
        })
      }
    });
  },
  // 重置input框
  clearInput() {
    this.setData({
      search_city: ''
    })
  },
  //点击完成按钮时触发：
  inputHandle(e) {
    var t = e.detail.value;
    var that = this;
    if (t = '') {
      return
    }
    that.setData({
      search_city: t
    })
  },
  changeCity(e) {
    app.choose_city = e.currentTarget.dataset.item;
    app.user_city_id = e.currentTarget.dataset.item.user_city_id;
    wx.navigateBack({

    })
    console.log(e.currentTarget.dataset.item)
  }
})